Clover coverage report - Enterprise Web Services - 1.0
Coverage timestamp: Mon May 30 2005 17:10:32 CEST
file stats: LOC: 118   Methods: 3
NCLOC: 73   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
SimpleLocalInterfaceBasedWrapperClassWriter.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * Copyright 2001-2004 The Apache Software Foundation.
 3   
  * 
 4   
  * Licensed under the Apache License, Version 2.0 (the "License");
 5   
  * you may not use this file except in compliance with the License.
 6   
  * You may obtain a copy of the License at
 7   
  * 
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  * 
 10   
  * Unless required by applicable law or agreed to in writing, software
 11   
  * distributed under the License is distributed on an "AS IS" BASIS,
 12   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  * See the License for the specific language governing permissions and
 14   
  * limitations under the License.
 15   
  */
 16   
 package org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs;
 17   
 
 18   
 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
 19   
 import org.apache.geronimo.ews.ws4j2ee.context.SEIOperation;
 20   
 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
 21   
 
 22   
 import java.util.ArrayList;
 23   
 import java.util.Iterator;
 24   
 
 25   
 /**
 26   
  * @author Srinath Perera(hemapani@opensource.lk)
 27   
  */
 28   
 public class SimpleLocalInterfaceBasedWrapperClassWriter extends EJBBasedWrapperClassWriter {
 29   
 
 30   
     /**
 31   
      * @param j2eewscontext
 32   
      * @throws GenerationFault
 33   
      */
 34  0
     public SimpleLocalInterfaceBasedWrapperClassWriter(J2EEWebServiceContext j2eewscontext)
 35   
             throws GenerationFault {
 36  0
         super(j2eewscontext);
 37  0
         seiName = context.getEjbLocalInterface();
 38   
     }
 39   
 
 40  0
     protected void writeMethods() throws GenerationFault {
 41  0
         out.write("\tpublic void setMessageContext(org.apache.axis.MessageContext msgcontext){;\n");
 42  0
         out.write("\t\tthis.msgcontext = msgcontext;\n");
 43  0
         out.write("\t}\n");
 44  0
         writeGetRemoteRef(classname);
 45  0
         String parmlistStr = null;
 46  0
         ArrayList operations = j2eewscontext.getMiscInfo().getSEIOperations();
 47  0
         for (int i = 0; i < operations.size(); i++) {
 48  0
             parmlistStr = "";
 49  0
             SEIOperation op = (SEIOperation) operations.get(i);
 50  0
             String returnType = op.getReturnType();
 51  0
             if (returnType == null)
 52  0
                 returnType = "void";
 53  0
             out.write("\tpublic " + returnType + " " + op.getMethodName() + "(");
 54  0
             Iterator pas = op.getParameterNames().iterator();
 55  0
             boolean first = true;
 56  0
             while (pas.hasNext()) {
 57  0
                 String name = (String) pas.next();
 58  0
                 String type = op.getParameterType(name);
 59  0
                 if (first) {
 60  0
                     first = false;
 61  0
                     out.write(type + " " + name);
 62  0
                     parmlistStr = parmlistStr + name;
 63   
                 } else {
 64  0
                     out.write("," + type + " " + name);
 65  0
                     parmlistStr = parmlistStr + "," + name;
 66   
                 }
 67   
             }
 68  0
             out.write(") throws java.rmi.RemoteException");
 69  0
             ArrayList faults = op.getFaults();
 70  0
             for (int j = 0; j < faults.size(); j++) {
 71  0
                 out.write("," + (String) faults.get(i));
 72   
             }
 73  0
             out.write("{\n");
 74  0
             out.write("\t\tif(ejb ==  null)\n");
 75  0
             out.write("\t\t\tejb = getRemoteRef();\n");
 76  0
             if (!"void".equals(returnType))
 77  0
                 out.write("\t\treturn ejb." + op.getMethodName() + "(" + parmlistStr + ");\n");
 78   
             else
 79  0
                 out.write("\t\tejb." + op.getMethodName() + "(" + parmlistStr + ");\n");
 80  0
             out.write("\t}\n");
 81   
         }
 82   
         //out.write("}\n");    
 83   
     }
 84   
 
 85  0
     private void writeGetRemoteRef(String classname) {
 86   
 //       out.write("\tpublic "+seiName+" getRemoteRef()throws org.apache.axis.AxisFault{\n");
 87   
 //       out.write("\t\ttry {\n");
 88   
 //       out.write("\t\t    javax.security.auth.callback.CallbackHandler handler\n");
 89   
 //       out.write("\t\t        = org.apache.geronimo.ews.ws4j2ee.wsutils.security.jaasmodules.\n");
 90   
 //       out.write("\t\t            AutenticationCallbackHandlerFactory.createCallbackHandler(msgcontext);\n");
 91   
 //       out.write("\t\t    if(handler != null){\n");
 92   
 //       out.write("\t\t        javax.security.auth.login.LoginContext lc\n"); 
 93   
 //       out.write("\t\t            = new javax.security.auth.login.LoginContext(\"TestClient\", handler);\n");
 94   
 //       out.write("\t\t        lc.login();\n");
 95   
 //       out.write("\t\t    }\n");
 96   
 //       out.write("\t\t}catch (javax.security.auth.login.LoginException e) {\n");
 97   
 //       out.write("\t\t     e.printStackTrace();\n");
 98   
 //       out.write("\t\t     throw org.apache.axis.AxisFault.makeFault(e);\n");
 99   
 //       out.write("\t\t}\n");
 100   
        
 101  0
         out.write("\t\ttry{\n");
 102  0
         String ejbname = j2eewscontext.getWSDLContext().getTargetPortType().getName().toLowerCase();
 103  0
         int index = ejbname.lastIndexOf(".");
 104  0
         if (index > 0) {
 105  0
             ejbname = ejbname.substring(index + 1);
 106   
         }
 107  0
         out.write("\t\t\tjavax.naming.Context initial = new javax.naming.InitialContext();\n");
 108  0
         out.write("\t\t\tObject objref = jndiContext.lookup(\"java:comp/env/ejb/\"" + ejbname + ");\n");
 109  0
         String ejbhome = j2eewscontext.getEJBDDContext().getEjbhomeInterface();
 110  0
         out.write("\t\t\t" + ejbhome + " home = (" + ejbhome + ")objref;\n");
 111  0
         out.write("\t\t\treturn home.create();\n");
 112  0
         out.write("\t\t}catch (Exception e) {\n");
 113  0
         out.write("\t\t    throw org.apache.axis.AxisFault.makeFault(e);\n");
 114  0
         out.write("\t\t}\n");
 115  0
         out.write("\t}\n");
 116   
     }
 117   
 }
 118